package com.mini.es.model;

import com.mini.mysql.model.MiniStatisticDataNew;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 项目名称：mini-data-es
 * 类 名 称：EsMiniStatisticPageParamNewModel
 * 类 描 述：TODO
 * 创建时间：2021/3/31 下午5:59
 * 创 建 人：zhanghuiying
 */
@ApiModel(value = "数据统计")
@Data
@Builder
@FieldNameConstants
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = EsMiniStatisticPageParamNewModel.index)
public class EsMiniStatisticPageParamNewModel implements Serializable {

    public static final String index = "mini_statistic_data_new";

    @Id
    private Long id;

    private String planName;
    @Field(type = FieldType.Keyword)
    private String planId;

    private Long pv;

    private Long uv;

    private Long formCardTotal;

    private Long payCardTotal;

    private Double courseMoney;

    private Long addWxTotal;

    private String workRoomId;

    private String workRoomName;
    @Field(type = FieldType.Keyword)
    private Long respId;

    private String respName;
    @Field(type = FieldType.Date)
    private Date createTime;
    @Field(type = FieldType.Date)
    private Date updateTime;

    private Integer isUsed;
    @Field(type = FieldType.Keyword)
    private Long miniLessonId;
    @Field(type = FieldType.Date)
    private Date miniDate;

    private Double bigCourseMoney;

    private Long appRegisterNum;

    private Long smsSendNum;

    private Long getCouponNum;

    private Double cash;

    private Double cost;

    private String campaignName;

    private Long click;

    private Long showCount;

    private String channelCode;

    private String channelName;

    private Long groupId;

    private String groupName;

    private Integer reception;

    private Integer preReception;

    private Integer adStatus;

    private String groupIds;

    private Long bigCourseOrderCount;

    private Double youzanMoney;

    private Double youzanMoneyAll;

    private Double companyMoney;

    private Double companyRefund;

    private Double youzanRefund;

    private Long liveSellCount;

    private Long liveSellCountAll;

    private Double liveSellMoney;

    private Double liveSellMoneyAll;

    private Double xcxMoney;

    private Double xcxMoneyAll;

    private Double xcxRefund;

    private Long xcxRefundCount;

    private Long youzanRefundCount;

    private Long companyRefundCount;

    private String miniLessonName;

    private Integer siteType;

    private Long chanceTotal;

    @Field(type = FieldType.Keyword)
    private String skuCode;
    @Field(type = FieldType.Keyword)
    private String idea;

    private String groupNames;

    private String unionId;

    private String lessonName;

    private Integer  itemId;

    private String itemName;

    private String xingtuSite;

    private String skuName;

    private String businessType;

    private String paySiteId;

    private String unPaySiteId;

    private String fields;
    @Field(type = FieldType.Keyword)
    private String lessonId;


    public EsMiniStatisticPageParamNewModel from(MiniStatisticDataNew b) {
        EsMiniStatisticPageParamNewModel s= Objects.isNull(b) ? null:
                EsMiniStatisticPageParamNewModel.builder()
                .adStatus(b.getAdStatus())
                .groupIds(b.getGroupIds())
                .groupId(b.getGroupId())
                .groupNames(b.getGroupNames())
                .groupName(b.getGroupName())
                .addWxTotal(b.getAddWxTotal())
                .appRegisterNum(b.getAppRegisterNum())
                .bigCourseMoney(b.getBigCourseMoney())
                .bigCourseOrderCount(b.getBigCourseOrderCount())
                .cash(b.getCash())
                .campaignName(b.getCampaignName())
                .chanceTotal(b.getChanceTotal())
                .channelCode(b.getChannelCode())
                .click(b.getClick())
                .channelName(b.getChannelName())
                .youzanRefundCount(b.getYouzanRefundCount())
                .companyMoney(b.getCompanyMoney())
                .companyRefund(b.getCompanyRefund())
                .cost(b.getCost())
                .createTime(b.getCreateTime())
                .courseMoney(b.getCourseMoney())
                .companyRefundCount(b.getCompanyRefundCount())
                .formCardTotal(b.getFormCardTotal())
                .getCouponNum(b.getGetCouponNum())
                .id(b.getId())
                .idea(Objects.isNull(b.getIdea()) || b.getIdea().equals("") ? "-1" : b.getIdea())
                .isUsed(b.getIsUsed())
                .liveSellCount(b.getLiveSellCount())
                .liveSellCountAll(b.getLiveSellCountAll())
                .liveSellMoney(b.getLiveSellMoney())
                .liveSellMoneyAll(b.getLiveSellMoneyAll())
                .miniDate(b.getMiniDate())
                .miniLessonId(Long.valueOf(b.getMiniLessonId()))
                .miniLessonName(b.getMiniLessonName())
                .payCardTotal(b.getPayCardTotal())
                .planId(b.getPlanId())
                .planName(b.getPlanName())
                .preReception(b.getPreReception())
                .pv(b.getPv())
                .reception(b.getReception())
                .respId(Objects.isNull(b.getRespId()) || b.getRespId().equals("null") ? null : Long.valueOf(b.getRespId()))
                .respName(b.getRespName())
                .showCount(b.getShowCount())
                .siteType(b.getSiteType())
                .skuCode(Objects.isNull(b.getSkuCode()) || b.getSkuCode().equals("") ? "-1" : b.getSkuCode())
                .smsSendNum(b.getSmsSendNum())
                .updateTime(b.getUpdateTime())
                .uv(b.getUv())
                .workRoomId(b.getWorkRoomId())
                .workRoomName(b.getWorkRoomName())
                .xcxMoney(b.getXcxMoney())
                .xcxMoneyAll(b.getXcxMoneyAll())
                .xcxRefund(b.getXcxRefund())
                .xcxRefundCount(b.getXcxRefundCount())
                .youzanMoney(b.getYouzanMoney())
                .youzanMoneyAll(b.getYouzanMoneyAll())
                .youzanRefund(b.getYouzanRefund())
                .youzanRefundCount(b.getYouzanRefundCount())
                .build();
        return s;
    }

}
